package com.chare.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chare.mapper.MenuRoleMapper;
import com.chare.pojo.MenuRole;
import com.chare.pojo.RespBean;
import com.chare.service.IMenuRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author shi
 * @since 2022-06-17
 */
@Service
public class MenuRoleServiceImpl extends ServiceImpl<MenuRoleMapper, MenuRole> implements IMenuRoleService {

    @Autowired
    private  MenuRoleMapper menuRoleMapper;
    @Override
    @Transactional
    public RespBean updateMenus(Integer rid, Integer[] mids) {

   menuRoleMapper.deleteById(rid);
   if(mids==null||mids.length==0)
   {
       return  RespBean.success("更新成功");

   }
       Integer menus= menuRoleMapper.insertRecod(rid,mids);
if(menus==mids.length)
{
    return RespBean.success("更新成功");
}
        return  RespBean.error("更新失败");
    }
}
